﻿#if UNITY_ANDROID && !UNITY_EDITOR
using UnityEngine;
#endif

namespace BToolkit
{
    public class SDCardPermission
    {

        /// <summary>
        /// 当前是否已经获得权限
        /// </summary>
        public static bool HavePermission()
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJavaClass jc = new AndroidJavaClass("cn.helper.SDCardPermission");
            return jc.CallStatic<bool>("haveSDCardPermission");
#else
            return true;
#endif
        }

        /// <summary>
        /// 申请权限（回调在MainActivity.cs里注册ActivityResult和RequestPermissionResult两个回调）
        /// </summary>
        public static void RequestSDCardPermission(int requestCode)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJavaClass jc = new AndroidJavaClass("cn.helper.SDCardPermission");
            jc.CallStatic("requestSDCardPermission", requestCode);
#endif
        }

    }
}